﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Net7Music_Api.BLL;
using Net7Music_Api.Model;
using Microsoft.AspNetCore.Cors;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace Net7Music_Api.Controllers
{

    [EnableCors("any")]
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UsersController : ControllerBase
    {
        // GET api/<UsersController>/5
        [HttpGet("{id}")]
        public List<User> GetUserByID(int id)
        {
            return UserManger.GetUserByID(id);
        }
        // POST api/<UsersController>/123/123
        [HttpPost("{name}/{pwd}")]
        public User Login(string name,string pwd)
        {
            var user = UserManger.GetUserLogin(name,pwd);
            if (user != null)
            {
                return user;
            }
            return user;
        }

        // PUT api/<UsersController>/5
        [HttpPut("{id}")]
        public void Put(int id, [FromBody] string value)
        {

        }

        // DELETE api/<UsersController>/5
        [HttpDelete("{id}")]
        public void Delete(int id)
        {

        }
    }
}
